﻿namespace Hidistro.UI.SaleSystem.Tags
{
    using Hidistro.Entities;
    using System;
    using System.Runtime.CompilerServices;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Xml;

    public class js_Common_ImageAd440 : WebControl
    {
        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write(this.RendHtml());
        }

        public string RendHtml()
        {
            XmlNode node = TagsHelper.FindAdNode(this.AdId, "image");
            StringBuilder builder = new StringBuilder();
            if (node != null)
            {
                builder.AppendFormat("<div class=\"adv_image cssEdite\" type=\"image\" id=\"ads_{0}\" >", this.AdId).AppendLine();
                if (!string.IsNullOrEmpty(node.Attributes["Url"].Value))
                {
                    builder.AppendFormat("<a target=\"_blank\" href=\"{0}\"><img src=\"{1}\" /></a>", node.Attributes["Url"].Value, node.Attributes["Image"].Value).AppendLine();
                }
                else
                {
                    builder.AppendFormat("<a target=\"_blank\"><img width=  \"254px\" height= \"440px\"  src=\"{0}\" /></a>", node.Attributes["Image"].Value).AppendLine();
                }
                builder.AppendLine("</div>");
            }
            return builder.ToString();
        }

        public int AdId { get; set; }
    }
}

